#pragma once

#include "HItemManager.h"
#include "GameItem.h"

namespace BombBox
{
	struct BombDamage
	{
		int m_nTarget;
		int m_nValue1;
		int m_nValue2;

		BombDamage( int nTarget, int nValue1, int nValue2 )
			: m_nTarget(nTarget), m_nValue1(nValue1), m_nValue2(nValue2){}
	};

	enum BombType
	{
		EBT_NULL		= 0,
		EBT_AROUND		= 1,
		EBT_CROSS		= 2,
		EBT_CUBE		= 3,
		EBT_DIRECT		= 4,
		EBT_DOWN		= 5,
		EBT_UP			= 6,
	};

	class GameItem_Bomb;

	class BombItem : public ItemListener, public GameItem
	{
	public:
		BombItem( GameItem_Bomb* pBomb );
		~BombItem( void );

	public:
		virtual const char* getItemName( void );
		virtual irr::core::stringc getItemMesh( int nStatus );
		virtual irr::core::stringc getItemPath( int nStatus );
		virtual bool getStatusAnimation( int nStatus );
		virtual int getAnimationSpeed( int nStatus );
		virtual void onAnimationStop( int nStatus );
		virtual bool enableLight( int nStatus );
		virtual const irr::core::vector3df& getPosition( int nStatus ) { return m_vPos; }

	public:
		void setItemController( ItemController* pItemController );
		ItemController* getItemController( void ) { return m_pItemController; }
		void setPosition( const irr::core::vector3df& vPos ){ m_vPos = vPos; }

	public:
		void doBomb( void );
		void toggleRotate( void );

		void doBomb_Cross( void );
		void doBomb_Around( void );
		void doBomb_Cube( void );
		void doBomb_Direct( void );
		void doBomb_Down( void );
		void doBomb_Up( void );

	protected:
		void doBomb( int x, int y, int z, int nDist = 1 );
	public:
		int getType();

	protected:
		GameItem_Bomb*			m_pBomb;
		ItemController*			m_pItemController;

		int						m_nRotateNum;
		irr::core::vector3df	m_vPos;
	};

	class GameItem_Bomb
	{
	public:
		GameItem_Bomb( void );
		~GameItem_Bomb( void );

	public:
		void setPath( irr::core::stringc sPath );
		void setFile( irr::core::stringc sFile );
		void setID( int nID );
		void setType( int nType );
		void setDist( int nDist );
		void addBombDamage( int nTargetID, int nValue1, int nValue2 );

	public:
		BombItem* createInstance( void );

	public:
		irr::core::stringc getFile( void );
		irr::core::stringc getPath( void );
		int getID( void );
		int getType( void );
		int getDist( void );
		bool getDamage( int nTarget, int& nValue1, int& nValue2 );

	protected:

		int					m_nID;
		int					m_nType;
		int					m_nDist;
		irr::core::stringc	m_sItem0;
		irr::core::stringc	m_sFilePath;

		int					m_nBombType;

		irr::core::map<int,BombDamage>	m_nDamageValue;
	};


	#define s_pBombManager (BombBox::BombManager::getSingletonPtr())

	class BombManager : public OSLib::Singleton<BombManager>
	{
	public:
		BombManager();
		~BombManager();

	public:
		void loadConfig( irr::core::stringc sFile );
		GameItem_Bomb* registerBox( int nTypeID );

	public:
		BombItem* createBomb( int nTypeID );


	protected:
		irr::core::map<int,GameItem_Bomb*>	m_vBombs;
	};
}